<template>
  <div class="anxu-container">
    <el-container>
      <el-aside width="200px">
        <el-menu
          default-active="/searchAnxu/myanxu"
          class="el-menu-vertical-demo"
          router
          background-color="#f5f7fa"
          active-text-color="#409EFF"
        >
          <!-- <el-menu-item index="/searchAnxu/myanxu">
            <i class="el-icon-document"></i>
            <span slot="title">我的安许</span>
          </el-menu-item>
          <el-menu-item index="/searchAnxu/allanxu" v-if="roleId !== '3'">
            <i class="el-icon-document"></i>
            <span slot="title">全部安许</span>
          </el-menu-item> -->
          <el-menu-item
            v-for="item in menuAnxuList"
            :key="item.path"
            :index="item.path"
          >
            <i class="el-icon-document"></i>
            <span slot="title">{{ item.name }}</span>
          </el-menu-item>
        </el-menu>
      </el-aside>
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
  </div>
</template>

<script>
export default {
  name: 'anxu-page',
  data () {
    return {
      roleId: 0,
      // 动态渲染菜单
      menuAnxuList: []
    }
  },
  created () {
    this.roleId = localStorage.getItem('crm-roleid')
    this.getAnxuMenuArr()
  },
  methods: {
    // 判断是什么角色  设置菜单的数组
    getAnxuMenuArr () {
      // 基础菜单
      const basePath = [{ path: '/searchAnxu/myanxu', name: '我的安许' }]
      // 管理员菜单
      const adminPath = [{ path: '/searchAnxu/allanxu', name: '全部安许' }]
      if (this.roleId === '1') {
        this.menuAnxuList = basePath.concat(adminPath)
      } else {
        this.menuAnxuList = basePath
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.anxu-container {
  height: 877px;
  .el-container {
    height: 877px;
    .el-aside {
      background-color: #f5f7fa;
      .el-menu {
        border: none;
      }
    }
    .el-main {
      padding: 20px;
    }
  }
}
</style>
<style>
/* 表格展开 效果 */
.demo-table-expand {
  font-size: 0;
}
.demo-table-expand label {
  width: 90px;
  color: #99a9bf;
}
.demo-table-expand .el-form-item {
  margin-right: 0;
  margin-bottom: 0;
  width: 50%;
}
</style>
